import React, { Component } from 'react';
import '../styles/Register.scss'
import { user_register } from "../api/index";
// import { debounce, throttle } from '../utils/tools';

class Register extends Component {
  constructor(props) {
    super(props)
    this.state = {
      phone: '', pass: '', passs: ''
    }
  }
  tongbu(e) {
    this.setState({ [e.target.name]: e.target.value })
  }
  register() {
    user_register(this.state).then((res) => {
      console.log(res.data);

    })
  }
  render() {
    return (
      <div className='register'>
        <h3>注册</h3>
        <div className="box">
          <input type="text" name='phone' placeholder='请输入用户名' value={this.state.phone} onChange={(e) => { this.tongbu(e) }} />
        </div>
        <div className="box">
          <input type="password" name='pass' placeholder='请输入密码' value={this.state.pass} onChange={(e) => { this.tongbu(e) }} />
        </div>
        <div className="box">
          <input type="password" name='passs' placeholder='确认密码' value={this.state.passs} onChange={(e) => { this.tongbu(e) }} />
        </div>
        <div className="box">
          <input type="button" value='注册' onClick={() => { this.register() }} />
        </div>
        <p>去登陆</p>
      </div>
    );
  }
}

export default Register;